package unit8.part4;

import javax.swing.*;

public class MenuTest {
    public static void main(String[] args) {
        JFrame jFrame = new JFrame("测试菜单");
        jFrame.setBounds(10, 10, 500, 500);

        JMenuBar menuBar = new JMenuBar();// 菜单栏
        JMenu menu = new JMenu("设置");// 菜单
        menuBar.add(menu);
        menu.add(new JMenuItem("用户管理"));// 菜单项
        menu.add(new JMenuItem("商品管理"));
        jFrame.setJMenuBar(menuBar);// 配置菜单栏

        JPopupMenu popupMenu = new JPopupMenu();// 弹出式菜单
        popupMenu.add(new JMenuItem("用户管理"));// 菜单项
        popupMenu.add(new JMenuItem("商品管理"));

        JPanel jPanel = new JPanel();
        jPanel.setComponentPopupMenu(popupMenu);// 配置弹出式菜单栏
        jFrame.add(jPanel);// 默认是边界布局

        jFrame.setVisible(true);
    }
}
